<?php
// +-------------------------------------------------------------------------------
// | DingZone [ A Rapid Development Framework For Dingtalk ]
// +-------------------------------------------------------------------------------
// | 前台首页 v1.0
// |
// | Copyright (c) 2014-2018 http://www.heimalanshi.com All rights reserved.
// | Author : Jie
// | Date : 2018-08-09
// +-------------------------------------------------------------------------------

namespace addons\index\controller;

use app\core\controller\CoreBaseController;
use think\Env;

class IndexController extends CoreBaseController {
    /**
     * 首页
     */
    public function index() {
        $eid = $this->_guessEid();
        if(empty($eid)) {
            $eid = Env::get("default_eid");
        }
        if (empty($eid)) {
            //如果没有指定eid，则跳转到首页
            $url = "http://ding.zone";
        } else {
            $url = "/core/enterprise?eid=" . $eid;
        }
        $this->redirect($url);
    }

    /**
     * 站点管理页面
     */
    public function site() {
        $this->redirect("/core/site");
    }

    /**
     * 页面跳转中转
     *
     * @return \think\response\View
     */
    public function jump() {
        $url = input("get.url");
        if (empty($url)) {
            $url = "http://ding.zone";
        }

        $from = input("get.from");
        $to = input("get.to");

        $this->assign("from", $from);
        $this->assign("to", $to);
        $this->assign("url", $url);

        if ($to == 'browser') {
            return view('jumpBrowser');
        } else if ($to == 'pc') {
            return view('jumpPc');
        } else if ($to == 'dingPc') {
            return view("jumpDingPc");
        } else if ($to == 'dingMobile') {
            return view("jumpDingMobile");
        }
    }
}